package com.wjerp.tplus.server.api.controller;

import com.wjerp.tplus.server.api.controller.base.BaseController;
import com.wjerp.tplus.server.api.request.AddFeedbackRequest;
import com.wjerp.tplus.server.common.exception.ServiceException;
import com.wjerp.tplus.server.common.model.BaseResponseData;
import com.wjerp.tplus.server.common.security.JwtUser;
import com.wjerp.tplus.server.common.utils.WjOpenApiUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author lishuailei
 */
@Api(tags = "反馈管理",description = "反馈相关API")
@RestController
@RequestMapping("feedback")
public class FeedbackController extends BaseController {

    @Resource
    private WjOpenApiUtils wjOpenApiUtils;

    @ApiOperation("意见反馈")
    @PostMapping("newFeedback")
    public ResponseEntity<BaseResponseData> newFeedback(
            @RequestBody AddFeedbackRequest request){
        try {
            JwtUser currentLoginUserInfo = getCurrentLoginUserInfo();
            wjOpenApiUtils.newFeedback(request,currentLoginUserInfo.getCompanyCode());
            return success(true);
        }catch (ServiceException e) {
            e.printStackTrace();
            return fail(e.getErrorCode(), e.getErrorMsg(), e);
        }
    }
}
